var rotate = function(matrix) {
    let halfLen = Math.floor(matrix.length / 2)
    for (let i = 0; i < halfLen; i++) {
        let temp = matrix[i]
        matrix[i] = matrix[matrix.length - 1 - i]
        matrix[matrix.length - 1 - i] = temp
    }
    console.log(halfLen, matrix)
    for (let j = 0; j < matrix.length; j++) {
        for (let k = j + 1; k < matrix.length; k++) {
            const item = matrix[j][k];
            matrix[j][k] = matrix[k][j]
            matrix[k][j] = item
        }
    }
    return matrix
};
console.log(rotate([
    [1, 2],
    [3, 4]
]))